<%@page contentType="text/html;charset=utf-8" %>
<%@taglib prefix="s" uri="/struts-tags" %> 
<script type="text/javascript">
function manage_sp_showcode(spId,id,codeType)
{
	var url = "mg/code/show.do";
    var content = "model.id=" + id 
			      +"&model.spId="+spId
				  +"&model.codeType="+codeType
    			  +"&spId="+spId
    			  +"&codeType="+codeType;
    var objectid = "manage_sp_showcodediv";
    sendXMLHttpRequest(url, content, objectid); 
}
function manage_sp_list()
{
	 var url = "mg/sp/list.do";
     var objectid = "content";
     var content = "";
     sendXMLHttpRequest(url, content, objectid); 
}
function manage_sp_listfilter(spId,id,codeType)
{
	var url = "mg/filter/list.do";
    var content = "model.spCodeId=" + id 
    			  +"&spId="+spId
    			  +"&codeType="+codeType;
    var objectid = "content";
    sendXMLHttpRequest(url, content, objectid); 
}
function manage_sp_listconfirm(spId,id,codeType)
{
	var url = "mg/confirm/list.do";
    var content = "model.spCodeId=" + id 
    			  +"&spId="+spId
    			  +"&codeType="+codeType;
    var objectid = "content";
    sendXMLHttpRequest(url, content, objectid); 
}
function manage_sp_listbantime(spId,id,codeType)
{
	var url = "mg/bantime/list.do";
    var content = "model.spCodeId=" + id 
    			  +"&spId="+spId
    			  +"&codeType="+codeType;
    var objectid = "content";
    sendXMLHttpRequest(url, content, objectid); 
}

function manage_sp_setcodeonline(id, type)
{
    var url = "mg/code/save.do";
    var content = "model.id=" + id
                + "&type=" + type;
    var objectid = "code_status_" + id;
    sendXMLHttpRequest(url, content, objectid); 
}
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="5"></td>
    <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="5"></td>
      </tr>
      <tr>
        <td height="25" class="t1">
          <img src="images/small0.gif" width="14" height="12"> 您现在的位置&gt;&gt;通道管理&gt;&gt;指令管理</td>
      </tr>
    </table>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="5"></td>
    <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>
        <table width="100%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="images/table_top_left.jpg" width="20" height="15" /></td>
            <td><img src="images/table_top_bg.jpg" width="770" height="15"/></td>
            <td align="right">
              <img src="images/table_top_right.jpg" width="20" height="15" /></td>
          </tr>
        </table>
        </td>
      </tr>
      <tr>
        <td height="25" class="table_blue">
        <input id="spId" type="hidden"  value="<s:property value="spInfo.id" />"/>
        <input id="spName" type="hidden" value="<s:property value="spInfo.spName" />"/>
          <strong><img src="images/dot.jpg" width="13" height="9">代码列表(通道：<s:property value="spInfo.spName" />--
          <s:property value="%{getConstantString('code type', codeType)}" />)</strong>
          <span style="float:right;color:#000000;">        
          <button id="btn2" dojoType="dijit.form.Button" 
            onclick="manage_sp_showcode('<s:property value="spId" />','-1','<s:property value="codeType"/>');">新增</button>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          </span>
          </td>
      </tr>   
      <tr>
        <td>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" 
           style="word-break:break-all;">
          <tr>
            <td align="center" class="table_g1" width="5%">ID</td>
	        <td align="center" class="table_g2" width="7%">运营商</td>
	        <td align="center" class="table_g2" width="10%">名称</td>
	        <td align="center" class="table_g2" width="5%">资费</td>
	        <s:if test='codeType.equals("1")||codeType.equals("2")'>
	        	<td align="center" class="table_g2" width="10%">指令</td>
	        	<td align="center" class="table_g2" width="10%">端口</td>
	        </s:if>
	        <s:else>
	        	<!-- td align="center" class="table_g2" width="15%">计费动作</td-->
	        </s:else>
	        <td align="center" class="table_g2" width="30%">开通省份</td>
	        <td align="center" class="table_g2" width="11%">状态</td>
	        <td align="center" class="table_g2" width="13%">&nbsp;</td>
	      </tr>
      
	      <s:if test="list.size()>0" >
	        <s:iterator value="list" status="stat" >
	        <tr onmouseover="this.style.background='#c0c0c0';" 
	            onmouseout="this.style.background='#ffffff';"> 
              <td class="table_w1" align="center"><s:property value="#stat.index+1" /></td>
	          <td class="table_w2" align="center"><s:property value="%{getConstantString('carrier', carrier)}" /></td>
               <td class="table_w2" align="center"><s:property value="codeName" /></td>
               <td class="table_w2" align="center"><s:property value="codefeevalue" /></td>
            <s:if test='codeType.equals("1")||codeType.equals("2")'>
	        	<td class="table_w2" align="center"><s:property value="smspaycode" /></td>
	        	<td class="table_w2" align="center"><s:property value="smspayport" /></td>
	        </s:if>
	        <s:else>
	        	<!-- td class="table_w2" align="center"><s:property value="basepayaction" /></td-->
	        </s:else>
	          <td class="table_w2" align="center"><s:property value="%{provinceToNameString(openProvince)}" /></td>
	          <td class="table_w2" align="center"><div id="code_status_<s:property value="id"/>"> 
	            <s:property value="%{getConstantString('code status',codeStatus)}"/>&nbsp;|&nbsp;
	            <s:if test="codeStatus==2">
	            <a href="javascript:void(0);" onclick="manage_sp_setcodeonline('<s:property value="id"/>','online')">上线</a>&nbsp;
	            <a href="javascript:void(0);" onclick="manage_sp_setcodeonline('<s:property value="id"/>','offline')">下线</a>
	            </s:if>
	            <s:elseif test="codeStatus==0">
	            <a href="javascript:void(0);" onclick="manage_sp_setcodeonline('<s:property value="id"/>','test')">测试</a>&nbsp;
	            <a href="javascript:void(0);" onclick="manage_sp_setcodeonline('<s:property value="id"/>','offline')">下线</a>
	            </s:elseif>
	            <s:else>
                <a href="javascript:void(0);" onclick="manage_sp_setcodeonline('<s:property value="id"/>','test')">测试</a>&nbsp;
	            <a href="javascript:void(0);" onclick="manage_sp_setcodeonline('<s:property value="id"/>','online')">上线</a>
	            </s:else>
	            <!-- a href="javascript:void(0);" title="<s:if test="status==0">点击下线</s:if><s:else>点击上线</s:else>" 
	                onclick="pi_setdeployedonline('<s:property value="id"/>', '<s:if test="status==0">offline</s:if><s:else>online</s:else>');"><s:property value="%{getConstantString('plugin status',status)}" /></a> -->
	                </div></td>
	          <td class="table_w2" align="center">
	            <a href="javascript:void(0);" 
	              onclick="manage_sp_showcode('<s:property value="spId" />','<s:property value="id" />','<s:property value="codeType"/>');">设置</a>&nbsp;
	            <a href="javascript:void(0);" 
	              onclick="manage_sp_listfilter('<s:property value="spId" />','<s:property value="id" />','<s:property value="codeType"/>');">屏蔽规则</a>
	              <br /><a href="javascript:void(0);" 
	              onclick="manage_sp_listconfirm('<s:property value="spId" />','<s:property value="id" />','<s:property value="codeType"/>');">二次确认</a>
	              &nbsp;
	            <a href="javascript:void(0);" 
	              onclick="manage_sp_listbantime('<s:property value="spId" />','<s:property value="id" />','<s:property value="codeType"/>');">禁止时段</a>&nbsp;
	            
	        </tr>    
	        
	        </s:iterator>
	      </s:if>
	      </table>
	    </td>
	  </tr>
      <tr>
      <td class="table_w1" align="center" height="30">
        <button id="btn1" dojoType="dijit.form.Button"
            onclick="return manage_sp_list();">返回</button>
      </td>      
     </tr>
      <tr> 
        <td background="images/table_bom_bg.jpg">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td>
              <img src="images/table_bom_left.jpg" width="20" height="15"></td>
            <td></td>
            <td align="right">
              <img src="images/table_bom_right.jpg" width="20" height="15"></td>
          </tr>
          </table>
        </td>
      </tr>
    </table>  
  </td>
  <td width="5"></td>
  </tr>
  </table>
  <div id="manage_sp_showcodediv"></div>
  <div id="manage_sp_listmtmsg"></div>